home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / BlobMgr / Library Folder / HitTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  1.3 KB  |  62 lines  |  [TEXT/KAHL]

  1. # include    "BlobMgr.h"
  2.  
  3.  
  4.  
  5.  
  6. /* -------------------------------------------------------------------- */
  7. /*                        Blob Hit Testing Routines                        */
  8. /* -------------------------------------------------------------------- */
  9.  
  10.  
  11. /*
  12.  * Test whether the blob contains the point, and if so, return a part
  13.  * of the part of the blob that the point is in.    Does not consider
  14.  * dimmed parts of blobs.    Blob must be active (enabled, not frozen).
  15.  * Return zero if no hit.
  16.  */
  17.  
  18. pascal short
  19. TestBlob (BlobHandle b, Point thePoint)
  20. {
  21. short    result;
  22.  
  23.     result = 0;
  24.     if (BlobActive (b))
  25.     {
  26.         if (!BlobDimmed (b, inDragBlob) && PtInRgn (thePoint, (**b).dragRgn))
  27.                 result = inDragBlob;
  28.         else if (!BlobDimmed (b, inStatBlob)
  29.             && PtInRgn (thePoint, (**b).statRgn))
  30.                 result = inStatBlob;
  31.     }
  32.     return (result);
  33. }
  34.  
  35.  
  36. /*
  37.  * If the point is in an undimmed region of any active blob of the set,
  38.  * return a handle to the blob in b and the part code as the function
  39.  * result.
  40.  */
  41.  
  42. pascal short
  43. FindBlob (Point thePoint, BlobSetHandle bSet, BlobHandle *bPtr)
  44. {
  45. BlobHandle    b;
  46. short        partCode;
  47. short        result;
  48.  
  49.     result = 0;
  50.     for (b = FirstBlob (bSet); b != nil; b = NextBlob (b))
  51.     {
  52.         partCode = TestBlob (b, thePoint);
  53.         if (partCode != 0)
  54.         {
  55.             result = partCode;
  56.             *bPtr = b;
  57.             break;
  58.         }
  59.     }
  60.     return (result);
  61. }
  62.